package com.sky.mapper;

import com.sky.entity.User;
import com.sky.vo.UserVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface UserMapper {

    /*
    * 根据openid查询用户
    * */
    @Select("select * from user where openid = #{openid}")
    User selectByOpenId(String openId);

    /*
    * 添加新用户
    * */
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void insert(User user);

    /**
     * 根据用户id查询用户
     * @param userId
     * @return com.sky.entity.User
     * @author zhupp
     * @create 2025/2/26
     **/
    @Select("select * from user where id = #{userId}")
    User getById(Long userId);

    /**
     * 获取每一天的新建用户的数量
     * @return java.util.List<com.sky.vo.UserVO>
     * @author zhupp
     * @create 2025/2/28
     **/
    List<UserVO> getNewUserCount();

    /**
     * 获取每一天的总的用户的数量
     * @return java.util.List<com.sky.vo.UserVO>
     * @author zhupp
     * @create 2025/2/28
     **/
    Integer getTotalUserCount(LocalDate date);
}
